package com.tronsis.distribution.biz.impl;


import android.app.Activity;

import com.google.gson.reflect.TypeToken;
import com.tronsis.distribution.bean.MyRecruitBean;
import com.tronsis.distribution.bean.RecruitBean;
import com.tronsis.distribution.biz.RecruitBiz;
import com.tronsis.distribution.http.Url;
import com.tronsis.library.http.HttpCallBack;
import com.tronsis.library.http.ListBean;
import com.tronsis.library.http.RequestClient;
import com.tronsis.library.http.RequestMethod;
import com.tronsis.library.http.UICallBack;

public class RecruitBizImpl implements RecruitBiz {


    @Override
    public void getRecruit(Activity activity, Integer page, Integer size, final UICallBack callBack) throws Exception {
        RequestClient.getInstance(new HttpCallBack(activity, new TypeToken<ListBean<RecruitBean>>(){}.getType()) {

            @Override
            public void onStart() {
                callBack.onStart();
            }

            @Override
            public void onCallBack(int status, Object result) {
                switch (status) {
                    case 200:
                        callBack.onRefresh(result);
                        break;
                    default:
                        callBack.onFailure(status);
                        break;
                }
            }
        }).addGetParams("page",String.valueOf(page),"size",String.valueOf(size)).excute(RequestMethod.GET, Url.RECRUIT);
    }

    @Override
    public void getRecruitCode(Activity activity, String quotaId, String region, final UICallBack callBack) throws Exception {
        RequestClient.getInstance(new HttpCallBack(activity,String.class) {

            @Override
            public void onStart() {
                callBack.onStart();
            }

            @Override
            public void onCallBack(int status, Object result) {
                switch (status) {
                    case 200:
                        callBack.onRefresh(result);
                        break;
                    default:
                        callBack.onFailure(status);
                        break;
                }
            }
        }).addGetParams("quotaId",quotaId,"region",region).excute(RequestMethod.GET,Url.RECRUIT_CODE);
    }

    @Override
    public void getRecruitMine(Activity activity, Integer page, Integer size, final UICallBack callBack) throws Exception {

        RequestClient.getInstance(new HttpCallBack(activity, new TypeToken<ListBean<MyRecruitBean>>(){}.getType()) {

            @Override
            public void onStart() {
                callBack.onStart();
            }

            @Override
            public void onCallBack(int status, Object result) {
                switch (status) {
                    case 200:
                        callBack.onRefresh(result);
                        break;
                    default:
                        callBack.onFailure(status);
                        break;
                }
            }
        }).addGetParams("page",String.valueOf(page),"size",String.valueOf(size)).excute(RequestMethod.GET,Url.RECRUIT_MIME);

    }
}
